Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pundit Integration #2399

Merged
merged 5 commits into from
Sep 19, 2015
Merged

Conversation

jayasi
Copy link
Contributor

@jayasi jayasi commented Sep 10, 2015

Integration of the Pundit gem. #2120

  • (Team CodeBenders, RGSoC'15)

@sferik
Copy link
Collaborator

sferik commented Sep 11, 2015

@jayasi The tests are failing on Travis CI? The problem appears to be:

/home/travis/build/sferik/rails_admin/spec/spec_helper.rb:9:in `require': cannot load such file -- pundit/rspec (LoadError)

Can you please look into fixing that?

@mshibuya
Copy link
Member

Version-specific Gemfiles under gemfiles/* also need to be updated, running

$ appraisal install

will do the job.

@@ -3,6 +3,7 @@ class MainController < RailsAdmin::ApplicationController
include ActionView::Helpers::TextHelper
include RailsAdmin::MainHelper
include RailsAdmin::ApplicationHelper
include Pundit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes Pundit required dependency, we should make it optional choice.

@jayasi
Copy link
Contributor Author

jayasi commented Sep 15, 2015

@sferik, @mshibuya Thank you for your feedback. Have made changes accordingly.

@record = record
end

def rails_admin?(action)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this issue?
We really need to get rid of this ugly case-when chain.

@jayasi
Copy link
Contributor Author

jayasi commented Sep 16, 2015

@sferik, @mshibuya, I've removed the need for the case-when chain by modifying the authorization adapter.

The CI test that is failing is for Ruby 2.2, but I am unable to reproduce it locally. I tried
BUNDLE_GEMFILE=/Users/jayasimehar/Desktop/rails_admin/gemfiles/rails_4.2.gemfile

CI_ORM=mongoid

bundle exec rspec ./spec/integration/config/edit/rails_admin_config_edit_spec.rb

And all tests are passing.

mshibuya added a commit that referenced this pull request Sep 19, 2015
@mshibuya mshibuya merged commit 4eecd02 into railsadminteam:master Sep 19, 2015
@mshibuya
Copy link
Member

LGTM

Merged in 🔨
Thanks so much, @Team-CodeBenders ❤️

@mshibuya
Copy link
Member

@jayasi @meghaarora42 Additionally, you may be interested in creating Wiki entry, which will promote use of this change.

@jayasi
Copy link
Contributor Author

jayasi commented Sep 19, 2015

@mshibuya Thank you 😄

We will create the wiki entry.

@meghaarora42
Copy link
Contributor

@mshibuya Thank you for all the help! :D

@dalpo
Copy link
Contributor

dalpo commented Sep 19, 2015

Thank you Rails Girls!!! 👏 👏 👏

687474703a2f2f7777772e7265616374696f6e676966732e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031332f31302f62696c6c2e676966

@kgrz
Copy link

kgrz commented Sep 19, 2015

👏🏼

@ronen
Copy link
Contributor

ronen commented Oct 15, 2015

Do you have a timeline for a (minor) release that includes this? I've already started using rails_admin with pundit (:clap: :clap: :clap:), but I'd rather not install from master branch. Thanks!

@md5
Copy link

md5 commented Dec 12, 2015

@jayasi Did you ever create a wiki entry for this? I'm not seeing one.

I'm wondering how access to the RailsAdmin dashboard is supposed to be authorized. I'm seeing RailsAdmin trying to call dashboard? on an ApplicationPolicy instance with policy.record = nil. It seems like it should be getting a RailsAdminPolicy with Pundit.policy(current_user, :rails_admin) and calling dashboard? on that.

Some guidance on how to use the :pundit authorization method would be appreciated.

@md5
Copy link

md5 commented Dec 12, 2015

I also see it trying to call history? on my model's policies when paper_trail integration is enabled.

@mxmzb
Copy link

mxmzb commented Apr 2, 2016

+1 would appreciate a wiki on this.

PS.: I liked the nested approach more, it gave you more power: bf63d68

@aeons
Copy link

aeons commented May 15, 2016

Anyone figured out how to use this?

@tquill
Copy link

tquill commented Jun 20, 2016

Any time frame for updating the documentation on this?

@masciugo
Copy link

masciugo commented Oct 5, 2016

@mxmzb
Copy link

mxmzb commented Oct 7, 2016

Since rails_admin 1.0 stable (worked in rc1) I am getting an undefined method 'policy' for #<RailsAdmin::MainController:0x007fcffdaf1c28> with Pundit integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.